AMD IOMMU: Destroy passthru guests when IO pagetable allocation fails
authorKeir Fraser <keir.fraser@citrix.com>
Fri, 14 Aug 2009 16:07:23 +0000 (17:07 +0100)
committerKeir Fraser <keir.fraser@citrix.com>
Fri, 14 Aug 2009 16:07:23 +0000 (17:07 +0100)
Signed-off-by: Wei Wang <wei.wang2@amd.com>
Acked-by: Wei Huang <wei.huang2@amd.com>
xen/drivers/passthrough/amd/iommu_map.c
xen/include/asm-x86/hvm/svm/amd-iommu-proto.h

index 352c52a182f2d5b19dfea13328cf72552c52dab6..ec06b194c9c4d77d7e2cb6a8289300cd5f071090 100644 (file)
@@ -426,7 +426,10 @@ static u64 iommu_l2e_from_pfn(struct page_info *table, int level,
             {
                 table = alloc_amd_iommu_pgtable();
                 if ( table == NULL )
+                {
+                    printk("AMD-Vi: Cannot allocate I/O page table\n");
                     return 0;
+                }
                 next_table_maddr = page_to_maddr(table);
                 amd_iommu_set_page_directory_entry(
                     (u32 *)pde, next_table_maddr, level - 1);
@@ -462,6 +465,7 @@ int amd_iommu_map_page(struct domain *d, unsigned long gfn, unsigned long mfn)
     {
         spin_unlock(&hd->mapping_lock);
         amd_iov_error("Invalid IO pagetable entry gfn = %lx\n", gfn);
+        domain_crash(d);
         return -EFAULT;
     }
     set_iommu_l1e_present(iommu_l2e, gfn, (u64)mfn << PAGE_SHIFT, iw, ir);
@@ -494,6 +498,7 @@ int amd_iommu_unmap_page(struct domain *d, unsigned long gfn)
     {
         spin_unlock(&hd->mapping_lock);
         amd_iov_error("Invalid IO pagetable entry gfn = %lx\n", gfn);
+        domain_crash(d);
         return -EFAULT;
     }
 
@@ -535,6 +540,7 @@ int amd_iommu_reserve_domain_unity_map(
             spin_unlock(&hd->mapping_lock);
             amd_iov_error("Invalid IO pagetable entry phys_addr = %lx\n",
                           phys_addr);
+            domain_crash(domain);
             return -EFAULT;
         }
 
@@ -583,6 +589,7 @@ int amd_iommu_sync_p2m(struct domain *d)
             spin_unlock(&d->page_alloc_lock);
             spin_unlock(&hd->mapping_lock);
             amd_iov_error("Invalid IO pagetable entry gfn = %lx\n", gfn);
+            domain_crash(d);
             return -EFAULT;
         }
 
index 64063219317de924168389e230654f1631ba1747..6664fbaed2c4501e24e2e5e3a610c86984c06018 100644 (file)
@@ -131,8 +131,10 @@ static inline struct page_info* alloc_amd_iommu_pgtable(void)
     void *vaddr;
 
     pg = alloc_domheap_page(NULL, 0);
+    if ( pg == NULL )
+        return 0;
     vaddr = map_domain_page(page_to_mfn(pg));
-    if ( !vaddr )
+    if ( vaddr == NULL )
         return 0;
     memset(vaddr, 0, PAGE_SIZE);
     unmap_domain_page(vaddr);